<template>
	<view>
		<u-mask :show="show" @click="show = false">
			<view class="warp">
				<view class="rects">
					<view :style="{backgroundImage:'url('+$ftpUrl('/index_coupond.png')+')'}"
						style="width:500rpx;height:700rpx;background-repeat: no-repeat;background-size: contain;text-align: center;color: #fff;">
						<view class="content">
							<view class="u-flex-2 u-row-around " style="display: flex;flex-direction: column;padding: 20rpx 0;">
								<view style="color: #FF5D39;font-size: 40rpx;font-weight: bold;">￥{{info.money}}</view>
								<view style="color: #FF5D39;font-size: 24rpx;" >{{info.couponName}}</view>
							</view>
							<view class="u-flex-1">
								<view style="color: #949494;font-size: 20rpx;border-top: 1rpx dashed #e1e1e1;padding: 20rpx;">您的新人券已放入优惠券包中哦~</view>
							</view>
							
						</view>
					</view>
				</view>
			</view>
		</u-mask>
	</view>
</template>


<script>
	import payway from '@/common/wxpay.js';
	import {
		mapGetters,
		mapMutations,
		mapState,
	} from 'vuex';
	
	export default {
		props: {
			goodId: {
				value: [String, Number],
				default: ''
			},

		},
		data() {
			return {
				show: false,
				info:{}
			}
		},
		computed:{
			...mapState(["userInfo"])
		},
		
		mounted(){
		
		},
		methods: {
			showPoup(){
				if(this.userInfo){
					if(!this.userInfo.first){
						this.$u.post('/index/couponDetail', {
						}).then(res => {
							if(res.id){
								this.info=res;
								 this.show=true;
								this.userInfo.first=1
								 this.$store.commit('SET_USERINFO', this.userInfo);
							}
						}).catch(err => {})
					}
				}
			},
			
			remove() {
				this.$u.post('/indent/removeLogo', {
					cases_id: this.goodId
				}).then(res => {
					if (!Array.isArray(res)) {
						var packages = res.package;
						var {
							noncestr,
							timestamp,
							signtype,
							paysign
						} = res
						payway.wx(timestamp, noncestr, packages, signtype, paysign).then(res => {
							this.$refs.uToast.show({
								title: '去水印成功',
								type: 'success',
								callback: () => {
									this.$emit("remove")
								}
							})
						}).catch(err => {

						})
					} else {
						this.$refs.uToast.show({
							title: '去水印成功',
							type: 'success',
							callback: () => {
								this.$emit("remove")
							}
						})
					}

				}).catch(err => {

				})
			}
		}
	}
</script>

<style scoped>
	.warp {
		display: flex;
		align-items: center;
		justify-content: center;
		height: 100%;
	}

	.rect {}

	.content {
		background: #FFFFFF;
		width: 300rpx;
		height: 200rpx;
		position: absolute;
		left: 50%;
		top: 50%;
		transform: translate(-50%, -70%);
		border-radius: 40rpx;
		padding: 20rpx 0;
		display: flex;
		justify-content: space-between;
		flex-direction: column;
	}
</style>
